<?php

/**
 * GreyBox Web User Control
 * @copyright 2010 by masmeka
 * @license contact to masmeka@gmail.com
 */
class Greybox {

    var $__gbUrlPath;

    function greybox($urlPath = "") {
        global $__CFG_http_gb;
        if ($urlPath != "")
            $this->__gbUrlPath = $urlPath;
        else
            $this->__gbUrlPath = $__CFG_http_gb;
    }

    function init() {
        echo "<script type=\"text/javascript\">" .
        "var GB_ROOT_DIR = \"" . $this->__gbUrlPath . "\";" .
        "</script>" .
        "<script type=\"text/javascript\" src=\"" . $this->__gbUrlPath . "AJS.js\"></script>" .
        "<script type=\"text/javascript\" src=\"" . $this->__gbUrlPath . "AJS_fx.js\"></script>" .
        "<script type=\"text/javascript\" src=\"" . $this->__gbUrlPath . "gb_scripts.js\"></script>" .
        "<link href=\"" . $this->__gbUrlPath . "gb_styles.css\" rel=\"stylesheet\" type=\"text/css\" />";
    }

    function createLink($url, $text, $caption = "", $cssclass = "", $event = "onclick", $width = "850", $height = "520") {
        $link = "<a title=\"" . $caption . "\"" .
                ($cssclass != "" ? " class=\"" . $cssclass . "\"" : "") .
                ($event != "onclick" ?
                        " onclick=\"return GB_showCenter('" . $caption . "', '" . $url . "', " . $height . ", " . $width . ")\"" :
                        " href=\"" . $url . "\" rel=\"gb_page_center[" . $width . ", " . $height . "]\"") .
                ">" . $text . "</a>";
        
        return $link;
    }

    function createButton($url, $text, $cssclass = "", $width = "800", $height = "480") {
        echo "<input type=\"button\" value=\"" . $text . "\"" .
        ($cssclass != "" ? " class=\"" . $cssclass . "\"" : "") .
        " onclick=\"return GB_showCenter('" . $caption . "', '" . $url . "', " . $height . ", " . $width . ")\"" .
        " />";
    }

}

function &CloseGB($withReloadParent = false, $url = "") {
    $strret = "";
    if ($withReloadParent) {
        if ($url != "")
            $strret = "var refurl = " . $url . ";";
        else
            $strret = "var refurl = parent.parent.window.location.href; parent.parent.window.location.href = refurl.replace('#','').replace('act=exp','').replace('act=reproceed', '').replace('act=rem', '');";
    }
    $strret .= "parent.parent.GB_hide();";

    return $strret;
}

?>
